//	DataTypes.h : User defined data types for network communication
//
#pragma once

#include "GradeIface.h"
#include "utils/configreader.h"
#include "kademliamain.h"

#include <Windows.h>
#include <stdio.h>

#include <exception>
#include <iostream>
#include <string>


namespace gKad {

	enum BOOTUP_RESULT {
		b_BOOTUP_OK = 0,		// boot-up ok
		b_BOOTUP_FAIL,			// boot-up node down
		b_BOOTUP_START_SERVER	// I'am boot-up node
	};

	class DataProvider {
	public:
		DataProvider(IAppAPI *);

		// Read config file and save data
		//
		bool ConfigRead(string);
		// Get key
		//
		string ConfigGetKey(string);
		// Performs bootstrap process for kademlia network
		// The boostrap node is loaded from config file.
		// 
		BOOTUP_RESULT Bootstrap();
		// Send ping and wait for response
		//
		//	Arg1 - destination address
		bool SendPing(TGradeAddr);

	protected:
		ConfigReader	*config;
		string			configFile;

	private:
		IAppAPI			*iApi;

		HANDLE			waitEventPing;

	};
}